import React from 'react';

export default class DemoSettingList extends React.Component {
  constructor(props) {
    super(props)
  }

  renderList() {
    var self = this;
    var content = [];
    if (this.props.data) {
      this.props.data.forEach(function(data, index) {
        content.push((
          <tr>
            <td>{data.name}</td>
            <td>{data.phone}</td>
            <td>
              <a onClick={(event)=>self.props.onDeleteClick(index)}>删除</a>
              <a className="edit" onClick={(event)=>self.props.onEditClick(index)}>编辑</a>
            </td>
          </tr>
        ))
      })
    }

    return content
  }

  render() {
    return(
      <div className="demo-setting-list">
        <table className="table table-bordered">
          <thead>
            <tr>
              <th>姓名</th>
              <th>手机号</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            {this.renderList()}
          </tbody>
        </table>
      </div>
    )
  }
}
